package day10;

import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Set;

public class Hashmap {
	public static void main(String[] args) {
		 HashMap<String, String> map = new HashMap<>();
		   map.put("CN", "中华人民共和国");
		   map.put("US", "美利坚合众国");
		   //根据key，找到这个key对应的这个值value
		   String value1 = map.get("CN");
		   System.out.println(value1);
		   System.out.println("------------");
		   // Map遍历
		   Set<Entry<String, String>> entrySet = map.entrySet();
		   for (Entry<String, String>    entry : entrySet) {
		     String key = entry.getKey() ;
		     String value = entry.getValue();
		     System.out.println("key: " + key);
		     System.out.println("value: " + value);
		   }
		   System.out.println("------------");
		   // keySet将map里面所有的key放到set集合
		   Set<String> keySet = map.keySet();
		   for (String key : keySet) {
		     System.out.println("key： " + key);
		     String value = map.get(key);
		     System.out.println("value: " + value);
		   }
	
}

}
